-- add_attrib
-- create by panyl
-- 属性提升N

return {
    apply = function(prop, baseValue)
        -- 提升的值
        return baseValue + prop[3];
    end,

    record = function(target, prop, path)
        -- 走默认的存储流程
        local v = target.dbase:queryTemp("prop", path, {});
        table.insert(v, prop);
        target.dbase:setTemp("prop", path, v);

        -- 某些属性
        if prop[2] == "defense" then
            EventMgr.fire(event.IMMEDIATE_UPDATE_MONSTER);
        end

        return true;
    end,

    desc = function(prop)
        local row = PropM.getRow(prop[1]);
        local desc = row.desc;

        local attrib = FieldsM.getFieldName(prop[2]);
        if attrib then
            desc = string.gsub(desc, "{0}", attrib);
        end

        -- 增加或减少这种,或是按数值变更符号的
        if prop[3] >= 0 then
            desc = string.gsub(desc, "{sign2}", "+");
        else
            desc = string.gsub(desc, "{sign2}", "");
        end

        if table.indexOf({"fire","armor","speed","luck"}, prop[2]) > 0 then
            desc = getLocStr("when_sky_combat") .. desc;
        end

        -- 如果是闪避或命中属性，替换数值时后面加%
        if "dodge" == prop[2] or "accuracy" == prop[2] then
            desc = string.gsub(desc, "{1}", prop[3] .. "%%");
        else
            desc = string.gsub(desc, "{1}", prop[3]);
        end

        return desc;
    end,

    title = function(prop)
        local row = PropM.getRow(prop[1]);
        if "dodge" == prop[2] and ActivityDungeonM.isInActivityDungeon() then
            -- 战争光环技能名称
            return SkillM.query(2215, "name");
        end

        return row.alias;
    end,
};
